package com.changcheng.project.acctinfo.controller;

import java.util.List;

import com.changcheng.project.userinfo.domain.AUserInfo;
import com.changcheng.project.userinfo.service.IAUserInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.changcheng.framework.aspectj.lang.annotation.Log;
import com.changcheng.framework.aspectj.lang.enums.BusinessType;
import com.changcheng.project.acctinfo.domain.AAcctInfo;
import com.changcheng.project.acctinfo.service.IAAcctInfoService;
import com.changcheng.framework.web.controller.BaseController;
import com.changcheng.framework.web.domain.AjaxResult;
import com.changcheng.common.utils.poi.ExcelUtil;
import com.changcheng.framework.web.page.TableDataInfo;

/**
 * 用户账户信息Controller
 * 
 * @author dazhi
 * @date 2020-11-02
 */
@Controller
@RequestMapping("/acctinfo/acctinfo")
public class AAcctInfoController extends BaseController
{
    private String prefix = "acctinfo/acctinfo";

    @Autowired
    private IAAcctInfoService aAcctInfoService;

    @RequiresPermissions("acctinfo:acctinfo:view")
    @GetMapping()
    public String acctinfo()
    {
        return prefix + "/acctinfo";
    }

    /**
     * 查询用户账户信息列表
     */
    @RequiresPermissions("acctinfo:acctinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AAcctInfo aAcctInfo)
    {
        startPage();
        List<AAcctInfo> list = aAcctInfoService.selectAAcctInfoList(aAcctInfo);
        return getDataTable(list);
    }

    /**
     * 导出用户账户信息列表
     */
    @RequiresPermissions("acctinfo:acctinfo:export")
    @Log(title = "用户账户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AAcctInfo aAcctInfo)
    {
        List<AAcctInfo> list = aAcctInfoService.selectAAcctInfoList(aAcctInfo);
        ExcelUtil<AAcctInfo> util = new ExcelUtil<AAcctInfo>(AAcctInfo.class);
        return util.exportExcel(list, "acctinfo");
    }

    /**
     * 新增用户账户信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户账户信息
     */
    @RequiresPermissions("acctinfo:acctinfo:add")
    @Log(title = "用户账户信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AAcctInfo aAcctInfo)
    {
        return toAjax(aAcctInfoService.insertAAcctInfo(aAcctInfo));
    }

    /**
     * 修改用户账户信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AAcctInfo aAcctInfo = aAcctInfoService.selectAAcctInfoById(id);
        mmap.put("aAcctInfo", aAcctInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户账户信息
     */
    @RequiresPermissions("acctinfo:acctinfo:edit")
    @Log(title = "用户账户信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AAcctInfo aAcctInfo)
    {
        return toAjax(aAcctInfoService.updateAAcctInfo(aAcctInfo));
    }

    /**
     * 删除用户账户信息
     */
    @RequiresPermissions("acctinfo:acctinfo:remove")
    @Log(title = "用户账户信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(aAcctInfoService.deleteAAcctInfoByIds(ids));
    }


    @Autowired
    private IAUserInfoService aUserInfoService;
    /**
     * 查询用户信息列表
     */

    @PostMapping("/userlist")
    @ResponseBody
    public TableDataInfo list()
    {
        startPage();
        List<AUserInfo> list = aUserInfoService.selectAUserInfoList(null);
        return getDataTable(list);
    }
}
